define([
    "ngController",
    "draggabilly"
],function (appAngular, draggabilly) {

    // 拖动模块-组件最外层（外部）
    appAngular.directive("bimviewApiDrag", function () {
        return {
            restrict: "EA",
            replace: true,
            template: `<div class="BIMView-API-drag">
                        <!-- 2、属性 -->
                        <div bim-api-model-property></div>
                        <!-- 3、模型结构 -->
                        <div bim-api-model-structure></div>
                        <!-- 4、视角书签 （和6、标注；公用一套CSS）-->
                        <div bim-api-model-eyesmark></div>
                        <!-- 5、搜索 -->
                        <div bim-api-model-search></div>
                        <!-- 6、标注 -->
                        <div bim-api-model-sign></div>
                        <!-- 7、剖切 -->
                        <div bim-api-model-section></div>
                        <!-- 9、定位 -->
                        <div bim-api-model-location></div>
                        <!-- 11、分解 -->
                        <div bim-api-model-resolve></div>
                        <!-- 12、设置 -->
                        <div bim-api-model-setting></div>
                        <!-- 遮罩层 -->
                        <div bim-api-model-layer></div>
					</div>`,
            link: function ($scope, $elem, attrs) {
                $elem.on("click", function () {
                    $scope.modelSliderShrink();
                    $scope.$apply();
                });

                // 拖动方法初始化（纯js调用三种方法+可查看方法的地址）
                // http://www.htmleaf.com/jQuery/Layout-Interface/201509142570.html
                // 第一种方法
                /*var elem = document.querySelector('.draggable');
                var draggie = new Draggabilly( elem, {
                  // options...
                });*/

                // 第二种方法
                /*let dragModule = new draggabilly('.draggable', {
                    containment: true
                });*/

                // 第三种方法;get all draggie elements
                let draggableElems = document.querySelectorAll('.draggable');
                let draggies = [];
                for (let i = 0, len = draggableElems.length; i < len; i++) {
                    let draggableElem = draggableElems[i];
                    let draggie = new draggabilly(draggableElem, {
                        containment: true
                    });
                    draggies.push(draggie);
                }
            }
        };
    });

    return appAngular;
});